from libs import common
from libs.db import DB


def save(data, request, cursor):
    now = common.get_ts()
    ip = common.get_ip(request)
    log_data = {
        'created': now,
        'ip': ip,
    }
    log_data.update(data)
    db = DB('cs_opt_logs', conn=cursor)
    return db.insert(log_data)
